package com.xiaoxiang.common.config;

import com.xiaoxiang.common.interceptor.TokenParamsInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: haha
 * @date: 2022/5/6 11:50
 */
@Configuration
@ConditionalOnProperty(value = "common.token-params", havingValue = "true", matchIfMissing = false)
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TokenParamsInterceptor()).addPathPatterns("/**");
    }
}

